﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CCWin;
using CCWin.SkinControl;
using CCWin.SkinClass;
using System.Runtime.InteropServices;
using System.Threading;
using System.Net.Mail;

namespace QQ2013
{
    public partial class FrmLogin : CCSkinMain
    {
        public FrmLogin()
        {
            InitializeComponent();
        }

        //窗口加载时
        private void FrmLogin_Load(object sender, EventArgs e)
        {
            int Hour = Convert.ToInt32(DateTime.Now.ToString("HH"));
            //早上
            if (Hour > 5 && Hour <= 11)
            {
                this.Back = Properties.Resources.morning;
            }
            else if (Hour > 11 && Hour <= 14)//中午
            {
                this.Back = Properties.Resources.noon;
            }
            else if (Hour > 14 && Hour <= 19)//下午
            {
                this.Back = Properties.Resources.afternoon;
            }
            else//晚上
            {
                this.Back = Properties.Resources.night;
            }
        }

        //状态菜单中的Item选择事件
        void item_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            txtId.Text = item.Tag.ToString();
        }

        //悬浮时
        private void Control_MouseEnter(object sender, EventArgs e)
        {
            Control txt = (Control)sender;
            SkinPanel pnl = (SkinPanel)txt.Parent;
            pnl.ControlState = ControlState.Hover;
        }

        //离开时
        private void Control_MouseLeave(object sender, EventArgs e)
        {
            Control txt = (Control)sender;
            SkinPanel pnl = (SkinPanel)txt.Parent;
            pnl.ControlState = ControlState.Normal;
        }

        //托盘图标双击显示
        private void tuopan_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
        }

        //登录事件
        private void btnDl_Click(object sender, EventArgs e)
        {
            if (txtId.Text.Length == 0 || txtPwd.Text.Length == 0) { return; }
            btnDl.Enabled = btnDuoId.Enabled = btnSandeng.Enabled = false;
            imgLoadding.Visible = true;
            timShow.Start();
        }

        //账号下拉框按钮事件
        private void btnId_Click(object sender, EventArgs e)
        {
        }

        //软键盘
        private void txtPwd_IconClick(object sender, EventArgs e)
        {
            PassKey pass = new PassKey(this.Left + txtPwd.Left - 25, this.Top + txtPwd.Bottom, txtPwd);
            pass.Show();
        }

        //自动登录
        private void chkZdLogin_CheckedChanged(object sender, EventArgs e)
        {
            chkMima.Checked = chkZdLogin.Checked ? true : chkMima.Checked;
        }

        //记住密码
        private void chkMima_CheckedChanged(object sender, EventArgs e)
        {
            if (!chkMima.Checked && chkZdLogin.Checked)
            {
                chkZdLogin.Checked = false;
            }
        }

        //计时器事件
        private void timShow_Tick(object sender, EventArgs e)
        {
            this.Close();
            tuopan.Text = String.Format("QQ：{0}({1})", txtId.Text, txtId.Text);
            timShow.Stop();
        }

        //QQ号栏失去焦点便将光标转移进密码栏
        private void txtId_Leave(object sender, EventArgs e)
        {
            txtPwd.Focus();
        }
    }
}
